package com.jzr.open.controller.api;

import com.jzr.common.BaseController;
import com.jzr.common.entity.vo.Result;
import com.jzr.open.db1.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@Api(tags = "用户接口")
@RestController
@RequestMapping(value = "/api/user")
public class UserController extends BaseController {
    @Autowired
    private UserService userService;

    @PostMapping("/logout")
    @ApiOperation("logout -> 注销登录")
    public Result<Boolean> logout(HttpServletRequest req) throws IOException {
        HttpSession session = req.getSession(false);
        if (session != null) {
            session.invalidate();
        }
        return Result.success("Logout成功", true);
    }


}